home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / openin < prev    next >
Text File  |  2006-10-19  |  4KB  |  183 lines

  1. **
  2. *
  3. *  OPEN INPUT
  4. *
  5. * Here we open a file for reading.  We must first make
  6. * sure that the file exists.  Then we make sure that the
  7. * attributes correspond.  Then and only then will we
  8. * open up the file.
  9. *
  10. **
  11.  
  12. OPENIN
  13.  
  14. * Check to see if we're opening a file or directory.
  15. * a directory specification will either be blank or
  16. * end with a period.
  17. *
  18.  
  19.        LDCR @B02,4           Select RAM bank 2
  20.        LI   R1,NCB+39
  21.  
  22. OIN0   CB   *R1,@PERIOD
  23.        JEQ  OIN0A
  24.        CB   *R1,@SPACE
  25.        JNE  OIN0B
  26.        DEC  R1
  27.        CI   R1,NCB-1
  28.        JNE  OIN0
  29. OIN0A  B    @OIN20
  30.  
  31. * See if the file exists
  32. *
  33. OIN0B  BL   @GETFDR
  34.        CI   R5,0
  35.        JNE  OIN1
  36.  
  37.        BL   @DSRERR
  38.        DATA >0700        File error
  39. OIN1
  40.  
  41. * We must first make sure the attributes match
  42. *
  43.        LDCR @ZERO,4           Select RAM bank 0
  44.        MOVB @PABBUF+4,R2      Get record length
  45.        JEQ  OIN3              If zero, it's OK
  46.        CB   R2,@17(R5)
  47.        JEQ  OIN3A
  48. OIN2   BL   @DSRERR
  49.        DATA >0200             Bad open attribute
  50.  
  51. * Store record length in caller's PAB
  52. *
  53. OIN3   MOV  @PABADR,R1
  54.        AI   R1,4
  55.        ORI  R1,>4000
  56.        SWPB R1
  57.        MOVB R1,@VDPWA
  58.        SWPB R1
  59.        MOVB R1,@VDPWA
  60.        MOVB @17(R5),@PABBUF+4
  61.        MOVB @17(R5),@VDPWD
  62.  
  63. OIN3A  MOVB @12(R5),R2        Get file flags
  64.        ANDI R2,>0100          Make sure it's not a program file
  65.        JNE  OIN2
  66.        MOVB @12(R5),R2
  67.        MOV  @PABBUF,R1        Check for Fixed/Variable
  68.        ANDI R1,>0010
  69.        MOV  R2,R3
  70.        ANDI R2,>8000
  71.        SRL  R2,11
  72.        C    R1,R2
  73.        JNE  OIN2
  74.  
  75.        MOV  @PABBUF,R1        Check for Display/Internal
  76.        ANDI R1,>0008
  77.        ANDI R3,>0200
  78.        SRL  R3,6
  79.        C    R1,R3
  80.        JNE  OIN2
  81.  
  82. * Check to see if we're opening the file for relative
  83. * or sequential access.
  84. *
  85. * For now, we are just handling sequential access.  If it's
  86. * relative, then the record type must be FIXED.
  87. *
  88.        MOV  @PABBUF,R1
  89.        ANDI R1,>0001         Check for relative file
  90.        JEQ  OIN10
  91.  
  92.        MOV  @PABBUF,R1        Check for Fixed/Variable
  93.        ANDI R1,>0010
  94.        JEQ  OIN10
  95.        BL   @DSRERR           Relative access - error
  96.        DATA >0300
  97.  
  98. * Everything is OK so far.  Set up the cache entry
  99. *
  100. OIN10  BL   @OSCASH
  101.  
  102. * Lets copy the FDR to its buffer
  103. *
  104.        LI   R0,256
  105.        MOV  @4(R4),R3        Get FDR address
  106.        MOVB @2(R4),R2
  107. OIN11  LDCR @ZERO,4
  108.        MOV  *R5+,R1
  109.        LDCR R2,4
  110.        MOV  R1,*R3+
  111.        DECT R0
  112.        JNE  OIN11
  113.        AI   R3,-256       Restore R3
  114.  
  115.        LDCR @ZERO,4
  116.        B    @DSRRT            Hooray!  We're done
  117.  
  118. **
  119. *
  120. * Here we are opening a directory for reading.  If the
  121. * directory exists, then set up an entry in the open file
  122. * cache.
  123. *
  124. **
  125.  
  126. * Make sure we are using fixed length records
  127. *
  128. OIN20  LDCR @ZERO,4
  129.        MOVB @PABBUF+1,R1
  130.        ANDI R1,>1000
  131.        JEQ  OIN20A
  132.  
  133. OIN20Z BL   @DSRERR
  134.        DATA >0700
  135. OIN20A
  136.  
  137. * Make sure the record length is set to 38 bytes
  138. *
  139.        MOVB @PABBUF+4,R1
  140.        JEQ  OIN20C
  141.        CB   R1,@B38
  142.        JNE  OIN20Z
  143. OIN20B BL   @GETDDR
  144.        CI   R5,0
  145.        JEQ  OIN20Z
  146.  
  147. OIN21  BL   @OSCASH
  148.        MOVB @B05,@56(R4)     Set file open attribute
  149.  
  150. * Now store the DDR in the buffer
  151. *
  152. OIN24
  153.        LI   R0,256
  154.        MOVB @2(R4),R2        DDR bank
  155.        MOV  @4(R4),R3        DDR Address
  156.  
  157. OIN25  LDCR @B03,4           Copy DDR to buffer
  158.        MOV  *R5+,R1
  159.        LDCR R2,4
  160.        MOV  R1,*R3+
  161.        DECT R0
  162.        JNE  OIN25
  163.  
  164.        LDCR @ZERO,4
  165.        B    @DSRRT
  166.  
  167. * We will store the record length in the PAB to see if
  168. * it makes BASIC happy
  169.  
  170. OIN20C MOVB @B38,@PABBUF+4
  171.        MOV  @PABADR,R1
  172.        AI   R1,4
  173.        ORI  R1,>4000
  174.        SWPB R1
  175.        MOVB R1,@VDPWA
  176.        SWPB R1
  177.        MOVB R1,@VDPWA
  178.        NOP
  179.        MOVB @B38,@VDPWD
  180.        JMP  OIN20B
  181.  
  182. B38    BYTE 38
  183.